package com.lzk.basic.interceptor.config;

/*import com.lzk.baisc.interceptor.LoginInterceptor;*/
import com.lzk.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 等同于xml配置
 */
@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) //使用的拦截器
                .addPathPatterns("/**")//拦截所有
                .excludePathPatterns("/fastDfs/**")//放行路径
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/register/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/register/phone")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");
    }
}
